package com.colien.service.impl;

import com.colien.dao.BookMapper;
import com.colien.pojo.Book;
import com.colien.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    //service调dao层：组合dao
    @Autowired
    @Qualifier("bookMapper")
    private BookMapper bookMapper;

    public void setBookMapper(BookMapper bookMapper) {
        this.bookMapper = bookMapper;
    }

    public int addBook(Book book) {
        return bookMapper.addBook(book);
    }

    public int deleteBook(int id) {
        return bookMapper.deleteBook(id);
    }

    public int updateBook(Book book) {
        return bookMapper.updateBook(book);
    }

    public Book queryBookById(int id) {
        return bookMapper.selectBook(id);
    }

    public List<Book> queryAllBook() {
        return bookMapper.selectBooks();
    }
}
